//
//  DDNotficationView.m
//  DingDongZP
//
//  Created by zurich on 16/3/27.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDNotficationView.h"

@interface DDNotficationView ()

@end

@implementation DDNotficationView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.vCount = 0;
        self.jCount = 0;
        
        // 通知相关
        self.notificationView = [[UIView alloc] init];
        self.notificationView.backgroundColor = [UIColor whiteColor];
        [self addSubview:_notificationView];
      
        self.iconImageView = [[UIImageView alloc] init];
        self.iconImageView.image = [UIImage imageNamed:@"message_notification"];
        [self.notificationView addSubview:_iconImageView];
        
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.text = @"通知";
        self.titleLabel.font = [UIFont systemFontOfSize:13.f];
        [self.notificationView addSubview:_titleLabel];
        
        self.notificationLabel = [[UILabel alloc] init];
        self.notificationLabel.textAlignment = NSTextAlignmentLeft;
        self.notificationLabel.text = @"0个人看过您,0个新职位";
        self.notificationLabel.textColor = [UIColor colorWithHexString:@"#ff8125"];
        self.notificationLabel.font = [UIFont systemFontOfSize:12.f];
        [self.notificationView addSubview:_notificationLabel];
        
        
        // 小叮咚相关
        self.littleDingDong = [[UIView alloc] init];
        self.littleDingDong.backgroundColor = [UIColor whiteColor];
        [self addSubview:_littleDingDong];
        
        self.iconImageView_DD = [[UIImageView alloc] init];
        self.iconImageView_DD.image = [UIImage imageNamed:@"小叮咚"];
        [self.littleDingDong addSubview:_iconImageView_DD];
        
        self.titleLabel_DD = [[UILabel alloc] init];
        self.titleLabel_DD.textAlignment = NSTextAlignmentLeft;
        self.titleLabel_DD.text = @"小叮咚";
        self.titleLabel_DD.font = [UIFont systemFontOfSize:13.f];
        [self.littleDingDong addSubview:_titleLabel_DD];
        
        self.notificationLabel_DD = [[UILabel alloc] init];
        self.notificationLabel_DD.textAlignment = NSTextAlignmentLeft;
        self.notificationLabel_DD.text = @"打开立即咨询吧";
        self.notificationLabel_DD.textColor = COLOR_FONT_DARK_GRAY;
        self.notificationLabel_DD.font = [UIFont systemFontOfSize:12.f];
        [self.littleDingDong addSubview:_notificationLabel_DD];
        
        
        // 最近联系的Boss/牛人
        self.connectView = [[UIView alloc] init];
//        self.connectView.backgroundColor = [UIColor colorWithHexString:@"#eef5f5"];
        [self addSubview:_connectView];

        UILabel *connectLabel = [[UILabel alloc] init];
        [connectLabel setTextColor:COLOR_FONT_MAIN_GREEN];
        if ([DDClientInfoManager clientType] == DDClientTypeCattle) {
            connectLabel.text = @"最近联系的Boss";
        } else {
            connectLabel.text = @"最近联系的牛人";
        }
        
        connectLabel.font = [UIFont systemFontOfSize:13.f];
        [self.connectView addSubview:connectLabel];
        
        //通知   布局
        [self.notificationView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).and.offset(10);
            make.left.equalTo(self);
            make.width.equalTo(self);
            make.height.mas_equalTo(@70.f);
        }];
        
        [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(@14.5);
            make.top.mas_equalTo(@8.f);
            make.size.mas_equalTo(CGSizeMake(50.f, 50.f));
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImageView.mas_right).and.offset(14.f);
            make.top.equalTo(self.iconImageView).and.offset(6.f);
            make.size.mas_equalTo(CGSizeMake(70.f, 18.f));
        }];
        
        [self.notificationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).and.offset(3.f);
            make.left.equalTo(self.titleLabel);
            make.width.equalTo(self).and.offset(-100);
            make.height.equalTo(self.titleLabel);
        }];
        
        
        //小叮咚   布局
        [self.littleDingDong mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.notificationView.mas_bottom).and.offset(10);
            make.left.equalTo(self);
            make.width.equalTo(self);
            make.height.mas_equalTo(@70.f);
        }];
        
        [self.iconImageView_DD mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(@14.5);
            make.top.mas_equalTo(@8.f);
            make.size.mas_equalTo(CGSizeMake(50.f, 50.f));
        }];
        self.iconImageView_DD.layer.masksToBounds = YES;
        self.iconImageView_DD.layer.cornerRadius = 25;
        
        [self.titleLabel_DD mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImageView_DD.mas_right).and.offset(14.f);
            make.top.equalTo(self.iconImageView_DD).and.offset(6.f);
            make.size.mas_equalTo(CGSizeMake(70.f, 18.f));
        }];
        
        [self.notificationLabel_DD mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel_DD.mas_bottom).and.offset(3.f);
            make.left.equalTo(self.titleLabel_DD);
            make.width.equalTo(self).and.offset(-100);
            make.height.equalTo(self.titleLabel_DD);
        }];
        
        
        // 最近联系的Boss/牛人 布局
        [self.connectView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self.littleDingDong.mas_bottom);
            make.left.equalTo(self);
            make.width.equalTo(self);
            make.height.mas_equalTo(@37.f);
        }];
        
        [connectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self.connectView);
            make.left.equalTo(self.connectView).and.offset(11);
            make.width.equalTo(self.connectView).and.offset(-11);
            make.height.equalTo(self.connectView);
        }];
        
     
        
    }
    return self;
}

- (void)setVCount:(NSInteger)vCount
{
    _vCount = vCount;
    [self reloadInfo];
}

- (void)setJCount:(NSInteger)jCount
{
    _jCount = jCount;
    [self reloadInfo];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)reloadInfo {
    self.notificationLabel.text = [NSString stringWithFormat:@"%ld个人看过您,%ld个新职位",_vCount, _jCount];
}

- (void)setJobViewCount:(NSInteger)viewCount newJobFinderCount:(NSInteger)newCount {
	self.notificationLabel.text = [NSString stringWithFormat:@"%ld个人查看过您的职位,%ld个新牛人",viewCount, newCount];
}

@end
